What is @elastic/apm-rum-core?
@elastic/apm-rum-core is a JavaScript library for Real User Monitoring (RUM) that allows you to measure the performance of your web applications. It helps you capture and analyze user interactions, page load times, and other performance metrics to improve the user experience.
What are @elastic/apm-rum-core's main functionalities?
Initialize APM
This code initializes the APM agent with the specified service name, server URL, and environment. Initialization is the first step to start monitoring your application.
const { init } = require('@elastic/apm-rum-core');
const apm = init({
serviceName: 'my-service',
serverUrl: 'http://localhost:8200',
environment: 'production'
});
Capture Page Load Metrics
This function captures the page load metrics, including the time it takes for the page to load and other relevant performance data.
apm.capturePageLoad();
Capture Custom Transactions
This code demonstrates how to capture custom transactions. You can start a transaction, perform some operations, and then end the transaction to capture its performance metrics.
const transaction = apm.startTransaction('custom-transaction', 'custom');
// Perform some operations
transaction.end();
Capture Errors
This code captures errors that occur in your application. It helps you track and analyze errors to improve the stability and reliability of your application.
try {
// Some code that might throw an error
} catch (error) {
apm.captureError(error);
}
Other packages similar to @elastic/apm-rum-core
newrelic
New Relic is a comprehensive monitoring tool that provides performance monitoring for web applications, servers, and infrastructure. It offers similar functionalities to @elastic/apm-rum-core, such as capturing page load metrics, custom transactions, and errors, but it also includes additional features like server monitoring and infrastructure monitoring.
datadog-rum
Datadog RUM (Real User Monitoring) is a service that provides end-to-end visibility into the performance of your web applications. It captures user interactions, page load times, and errors, similar to @elastic/apm-rum-core. Datadog RUM integrates seamlessly with other Datadog services, providing a unified monitoring solution.
sentry
Sentry is an open-source error tracking tool that helps developers monitor and fix crashes in real-time. While it primarily focuses on error tracking, it also provides performance monitoring features similar to @elastic/apm-rum-core, such as capturing transactions and measuring page load times.
Elastic APM JavaScript core (for development)
This is the core JavaScript module for Elastic APM.
Only use this package if you want to implement an integration for a framework that Elastic APM does not support yet.
Documentation
You can find our documentation on our website.
If you are interested in contributing to Elastic APM JavaScript agent, please see our contributing guide.
We'd love to hear your feedback, please take a minute to fill out our survey.
License
This project is MIT licensed.
Made with ♥️ and ☕️ by Elastic and our community.